home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Found / FWStream / FWMemSin.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  2.5 KB  |  82 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWMemSin.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWMEMSIN_H
  11. #define FWMEMSIN_H
  12.  
  13. #include "SLMemSin.xh"
  14.  
  15. #ifndef FWRANSIN_H
  16. #include "FWRanSin.h"
  17. #endif
  18.  
  19. //========================================================================================
  20. //    CLASS FW_PMemorySink
  21. //
  22. //        Inherited API for operator->()
  23. //            long GetReadableBytes();
  24. //            void Read(in void * destination, in long count);
  25. //            long GetWritableBytes();
  26. //            void Write(in void* source, in long count);
  27. //
  28. //            long GetLength();
  29. //            void SetLength(in long length);
  30. //            long GetPosition();
  31. //            void SetPosition(in long position);
  32. //
  33. //========================================================================================
  34.  
  35. class FW_PMemorySink : public FW_PRandomAccessSink
  36. {
  37. public:
  38.     FW_PMemorySink(Environment* ev, FW_OMemorySink* theMemorySink);
  39.     FW_PMemorySink(Environment* ev, void* buffer, long capacity, long length);
  40.         // Construct a memory sink given the buffer and the maximum capacity 
  41.         // of the buffer.  The length is the number of bytes which have been 
  42.         // written to the buffer.
  43.  
  44.     virtual ~FW_PMemorySink();
  45.  
  46. public:
  47.     // Covariant overrides
  48.     FW_OMemorySink*     GetRep()            const;
  49.     FW_OMemorySink*     operator->()        const;
  50.     operator             FW_OMemorySink*()    const;
  51.  
  52. private:
  53.     FW_PMemorySink(const FW_PMemorySink&);
  54.     FW_PMemorySink& operator=(const FW_PMemorySink&);
  55. };
  56.  
  57. //----------------------------------------------------------------------------------------
  58. //    FW_PMemorySink::GetRep
  59. //----------------------------------------------------------------------------------------
  60. inline FW_OMemorySink* FW_PMemorySink::GetRep() const
  61. {
  62.     return (FW_OMemorySink*)FW_PRandomAccessSink::GetRep();
  63. }
  64.  
  65. //----------------------------------------------------------------------------------------
  66. //    FW_PMemorySink::operator->
  67. //----------------------------------------------------------------------------------------
  68. inline FW_OMemorySink* FW_PMemorySink::operator->() const
  69. {
  70.     return GetRep();
  71. }
  72.  
  73. //----------------------------------------------------------------------------------------
  74. //    FW_PMemorySink::operator FW_OMemorySink*
  75. //----------------------------------------------------------------------------------------
  76. inline FW_PMemorySink::operator FW_OMemorySink*() const
  77. {
  78.     return GetRep();
  79. }
  80.  
  81. #endif
  82.